<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no, email=no">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="full-screen" content="yes">
    <meta name="browsermode" content="application">
    <meta name="screen-orientation" content="portrait">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>dld</title>
    <link href="/dld/home/css/sweetalert.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <style>
    html {
        height: 100%;
    }
    
    body {
        height: 100%;
        background: linear-gradient(rgb(204, 255, 153), rgb(204, 255, 255)) fixed;
		background-size: cover;
        overflow-x: hidden;
        font-family: SimSun;
        color: rgba(255, 255, 255, 0.8);
    }
    /*暗影*/
    
    .box-shadow {
        box-shadow: 0 0 10px 2px rgba(0, 0, 0, 1);
    }
    
    p.frist-p {
        font-size: 18px;
        margin: 10px 0 0 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding-right: 0;
    }
    
    p.frist-p.s-p {
        font-size: 14px !important;
        color:rgba(0,0,0,1);
    }

    div.user-detail-left{
        position: absolute;
    }
    div.user-detail-right{
        position: absolute;
        left: 120px;
        margin:10px 0;
    }
    a.tab:hover{
    	background-color: rgb(84,84,84);
    	color:rgba(255,255,255,0.8);
    }
    .tab{
    	background-color: rgb(33,33,34);
    	color:rgba(255,255,255,0.8);
    	border: 1px solid rgba(255, 255, 255, .15);
    	border-radius: 0;
    }
    .ctrl-tab{
    	background-color: rgb(84,84,84);
    	color:rgba(255,255,255,0.8);
    	border: 1px solid rgba(255, 255, 255, .15);
    	border-radius: 0;
    }
    .btn-click{
    	width:100%;
    	height:100%;
    	background-color:rgba(33,33,34,.5);
    	border-radius:20px;
    }
	#l-map{height:0;width:100%;}
	#r-result,#r-result table{width:100%;}
	.fight-main p{
	margin:0;
	}
    </style>
</head>

<body id="app">
    <nav class="navbar navbar-top" style="background-color: rgb(51, 51, 51);margin-bottom: 0;">
        <div class="col-xs-3" onclick="window.location.href='MsgAction'">
            <span class="glyphicon glyphicon-home pull-left" style="font-size: 18px;margin-top: 13px;"></span>
        </div>
        <div class="col-xs-6" align="center">
            <p style=";font-size: 27px;margin: 5px 0 0 0;">dld</p>
        </div>
        <div class="col-xs-3" onclick="window.location.href='logoutUsersAction'">
            <span class="glyphicon glyphicon-off pull-right" style="font-size: 18px;margin-top: 13px;"></span>
        </div>
    </nav>
    <div v-show="main_ctrl">
    <div class="row-fluid" style="height: 140px;">
        <div class="user-detail-left" style="width: 120px;">
            <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=622578697,1657698698&fm=116&gp=0.jpg" alt="" class="img-circle box-shadow" style="height:100px;margin: 20px 10px;">
        </div>
        <div class="user-detail-right">
            <p class="frist-p s-p col-xs-6">
            	${users.name} <s:if test="users.sex == \"男\"">♂</s:if><s:else>♀</s:else>
            </p>
            <p class="frist-p s-p col-xs-6">属性:<s:if test="users.gameInfo.main_type == 'll'">力量</s:if><s:elseif test="users.gameInfo.main_type == 'mj'">敏捷</s:elseif><s:else>智力</s:else></p>
            <p class="frist-p s-p col-xs-6">生命:{{hp}}</p>
            <p class="frist-p s-p col-xs-6">攻击:{{ad}}</p>
            <p class="frist-p s-p col-xs-6">法强:{{ap}}</p>
            <p class="frist-p s-p col-xs-6">护甲:{{hj}}</p>
            <p class="frist-p s-p col-xs-6">获得:{{get_money}}</p>
        </div>
    </div>
    
    <div class="row-fluid">
    	<div class=" col-xs-9 tab text-center show-money" style="padding:6px 12px;background-color: rgba(33,33,34,.4);">￥{{money}}({{earn}})</span></div>
        <button class=" col-xs-3 btn tab money-update" style="background-color: rgba(33,33,34,.4);"><span class="glyphicon glyphicon-refresh"></span></button>
        
        <div class=" col-xs-9 tab text-center gps" style="padding:6px 12px;background-color: rgba(33,33,34,.4);">x y</div>
        <button class=" col-xs-3 btn tab gps-update" style="background-color: rgba(33,33,34,.4);" onclick="getLocation();"><span class="glyphicon glyphicon-refresh"></span></button>
        
    	<a href="#controller" aria-controls="controller" role="tab" data-toggle="tab" class="col-xs-3 btn tab">操作</a>
        <a href="#goods" aria-controls="goods" role="tab" data-toggle="tab" class="col-xs-3 btn tab">物品栏</a>
        <a href="#skill" aria-controls="skill" role="tab" data-toggle="tab" class="col-xs-3 btn tab">技能栏</a>
        <a href="#set" aria-controls="set" role="tab" data-toggle="tab" class="col-xs-3 btn tab"><span class="glyphicon glyphicon-cog"></span></a>
    </div>
    
	<div class="tab-content" style="background-color: rgba(33,33,34,.4);">
	
	  <div role="tabpanel" class="tab-pane fade in active" id="controller">
	  	<div class="col-xs-12" style="padding:0;">
	        <div class="col-xs-6 text-center" style="height:100px;padding:5px 5px">
	        	<div class="box-shadow btn-click money"><h1 style="padding-top:25px;margin:0">点钱</h1></div>
	        </div>
	        <div class="col-xs-6 text-center" style="height:100px;padding:5px 5px" v-on:click="searchFight()">
	        	<div class="box-shadow btn-click"><h1 style="padding-top:25px;margin:0">匹配</h1></div>
	        </div>
	        <a href="#" class="col-xs-6 btn btn-lg ctrl-tab" v-on:click="friendsShow()">查看好友</a>
	        <a href="#" class="col-xs-6 btn btn-lg ctrl-tab" v-on:click="changeShow()">附近的人</a>
	        <a href="#" class="col-xs-6 btn btn-lg ctrl-tab" v-on:click="search()">寻找宝藏（2000）</a>
	        <a href="#" class="col-xs-6 btn btn-lg ctrl-tab dug">挖掘宝藏</a>
	        <div class="col-xs-12 btn-lg ctrl-tab texe-center" v-if="this.dug_location != ''">{{dug_location}}</div>
	        <div class="col-xs-12 btn-lg ctrl-tab text-center" style="opacity:0.7">游戏详细信息</div>
	        <div class="col-xs-6 btn-lg ctrl-tab text-center">力量:{{ll}}</div>
	        <div class="col-xs-6 btn btn-lg ctrl-tab text-center" v-on:click="upProperty(ll,'ll')">{{ll * 100}}<spna class="glyphicon glyphicon-chevron-right"></spna></div>
	        <div class="col-xs-6 btn-lg ctrl-tab text-center">敏捷:{{mj}}</div>
	        <div class="col-xs-6 btn btn-lg ctrl-tab text-center" v-on:click="upProperty(mj,'mj')">{{mj * 100}}<spna class="glyphicon glyphicon-chevron-right"></spna></div>
	        <div class="col-xs-6 btn-lg ctrl-tab text-center">智力:{{zl}}</div>
	        <div class="col-xs-6 btn btn-lg ctrl-tab text-center" v-on:click="upProperty(zl,'zl')">{{zl * 100}}<spna class="glyphicon glyphicon-chevron-right"></spna></div>
	        <div class="col-xs-6 btn-lg ctrl-tab text-center">点钱等级:{{get_money}}</div>
	        <div class="col-xs-6 btn btn-lg ctrl-tab text-center"  v-on:click="upGetMoney()">{{fib}}<spna class="glyphicon glyphicon-chevron-right"></spna></div>
	        
	        <div id="l-map"></div>
	        <div id="r-result" class="ctrl-tab"></div>
	  	</div>
	  </div>

	  <div role="tabpanel" class="tab-pane fade" id="goods">
        <div class="col-xs-12" style="padding: 0;background-color: rgb(84, 84, 84);margin-bottom: 1px;">
            <p class="frist-p text-center">装备</p>
        </div>
	  	<s:iterator value="users.goodsUse" status="st" var="list">
	      <div class="col-xs-12" style="background-color: rgb(84, 84, 84);margin-bottom: 1px;">
	          <div class="col-xs-10" style="padding: 0;">
	              <p class="frist-p"><s:property value="#list.getName()"/></p>
	              <span style="font-size:10px;"><s:property value="#list.getContent()"/> </span>
	          </div>
	          <a class="col-xs-2" style="padding: 0;font-size: 27px;margin-top:14px;color:rgba(255,255,255,0.8)" href="goodsRemoveAction?type=goodsUse&id=<s:property value='#st.index'/>">
	             	<span class="glyphicon glyphicon-circle-arrow-right pull-right"></span>
	          </a>
              <p style="font-size:10px;padding: 0;" class="col-xs-12">
              HP:<s:property value="#list.getHp()"/>
              AP:<s:property value="#list.getAp()"/>
              AD:<s:property value="#list.getAd()"/>
              HJ:<s:property value="#list.getHj()"/>
              Ll:<s:property value="#list.getLl()"/>
              MJ:<s:property value="#list.getMj()"/>
              ZL:<s:property value="#list.getZl()"/>
              TYPE:<s:property value="#list.getType()"/>
              </p>
	      </div>
	  	</s:iterator>
	  
	    <div class="col-xs-12" style="padding: 0;background-color: rgb(84, 84, 84);margin-bottom: 1px;">
            <p class="frist-p text-center">拥有</p>
        </div>
	  	<s:iterator value="users.goodsItem" status="st" var="list">
	      <div class="col-xs-12" style="background-color: rgb(84, 84, 84);margin-bottom: 1px;">
	          <div class="col-xs-10" style="padding: 0;">
	              <p class="frist-p"><s:property value="#list.getName()"/></p>
	              <span style="font-size:10px;"><s:property value="#list.getContent()"/> </span>
	          </div>
	          <a class="col-xs-2" style="padding: 0;font-size: 27px;margin-top:14px;color:rgba(255,255,255,0.8)" href="goodsRemoveAction?type=goodsItem&id=<s:property value='#st.index'/>">
	             	<span class="glyphicon glyphicon-circle-arrow-right pull-right"></span>
	          </a>
              <p style="font-size:10px;padding: 0;" class="col-xs-12">
              HP:<s:property value="#list.getHp()"/>
              AP:<s:property value="#list.getAp()"/>
              AD:<s:property value="#list.getAd()"/>
              HJ:<s:property value="#list.getHj()"/>
              Ll:<s:property value="#list.getLl()"/>
              MJ:<s:property value="#list.getMj()"/>
              ZL:<s:property value="#list.getZl()"/>
              TYPE:<s:property value="#list.getType()"/>
              </p>
	      </div>
	  	</s:iterator>
	  </div>
	  
	  <div role="tabpanel" class="tab-pane fade" id="skill">
	    <div class="col-xs-12" style="padding: 0;background-color: rgb(84, 84, 84);margin-bottom: 1px;">
            <p class="frist-p text-center">装备</p>
        </div>
	  	<s:iterator value="users.skillUse" status="st" var="list">
	      <div class="col-xs-12" style="background-color: rgb(84, 84, 84);margin-bottom: 1px;">
	          <div class="col-xs-10" style="padding: 0;">
	              <p class="frist-p"><s:property value="#list.getName()"/></p>
	              <p class="second-p"><s:property value="#list.getContent()"/> </p>
	          </div>
	          <a class="col-xs-2" style="padding: 0;font-size: 27px;margin-top:14px;color:rgba(255,255,255,0.8)" href="goodsRemoveAction?type=skillUse&id=<s:property value='#st.index'/>">
	             	<span class="glyphicon glyphicon-circle-arrow-right pull-right"></span>
	          </a>
	          <p style="font-size:10px;padding: 0;" class="col-xs-12">
              HURT:<s:property value="#list.getHurt()"/>
              HP:<s:property value="#list.getHp()"/>
              AP:<s:property value="#list.getAp()"/>
              AD:<s:property value="#list.getAd()"/>
              HJ:<s:property value="#list.getHj()"/>
              Ll:<s:property value="#list.getLl()"/>
              MJ:<s:property value="#list.getMj()"/>
              ZL:<s:property value="#list.getZl()"/>
              POSSIBLE:<s:property value="#list.getPossible()"/>
             </p>
	      </div>
	  	</s:iterator>
	  	
        <div class="col-xs-12" style="padding: 0;background-color: rgb(84, 84, 84);margin-bottom: 1px;">
            <p class="frist-p text-center">拥有</p>
        </div>
	  	<s:iterator value="users.skillItem" status="st" var="list">
	      <div class="col-xs-12" style="background-color: rgb(84, 84, 84);margin-bottom: 1px;">
	          <div class="col-xs-10" style="padding: 0;">
	              <p class="frist-p"><s:property value="#list.getName()"/></p>
	              <p class="second-p"><s:property value="#list.getContent()"/> </p>
	          </div>
	          <a class="col-xs-2" style="padding: 0;font-size: 27px;margin-top:14px;color:rgba(255,255,255,0.8)" href="goodsRemoveAction?type=skillItem&id=<s:property value='#st.index'/>">
	             	<span class="glyphicon glyphicon-circle-arrow-right pull-right"></span>
	          </a>
	          <p style="font-size:10px;padding: 0;" class="col-xs-12">
              HURT:<s:property value="#list.getHurt()"/>
              HP:<s:property value="#list.getHp()"/>
              AP:<s:property value="#list.getAp()"/>
              AD:<s:property value="#list.getAd()"/>
              HJ:<s:property value="#list.getHj()"/>
              Ll:<s:property value="#list.getLl()"/>
              MJ:<s:property value="#list.getMj()"/>
              ZL:<s:property value="#list.getZl()"/>
              POSSIBLE:<s:property value="#list.getPossible()"/>
              </p>
	      </div>
	  	</s:iterator>
	  </div>
	  
	  <div role="tabpanel" class="tab-pane fade" id="set">
	  	<div class="col-xs-12" style="padding:0;">
	  		<a href="getLogAction" class="col-xs-12 btn btn-lg ctrl-tab">游戏日志</a>
	        <a href="/dld/home/help.jsp" class="col-xs-12 btn btn-lg ctrl-tab">帮助说明</a>
	        <a href="UsersTopAction?topType=money" class="col-xs-12 btn btn-lg ctrl-tab">排行榜</a>
	        <textarea class="col-xs-12 ctrl-tab" rows="5" v-model="feedback"></textarea>
	        <a href="#" class="col-xs-12 btn btn-lg ctrl-tab" v-on:click="submitFB()">提交反馈</a>
	        <s:if test="users.power == 0">
	        	<a href="/dld/admin/index.jsp" class="col-xs-12 btn btn-lg ctrl-tab">返回后台</a>
	        </s:if>
	  	</div>
	  </div>
	</div>
	</div>
	
	<div v-show="!main_ctrl">
		<div v-show="nearby_show">
		<div class="col-xs-12" style="padding:0;margin-bottom:34px;">
	        <div class="col-xs-12 btn-lg ctrl-tab" v-for="nb in nearby">
	        	<div class="col-xs-10">
	        	{{nb.name}}<br/>
	        	{{nb.distance}}
	        	</div>
	        	<span class="glyphicon glyphicon-scissors" v-on:click="searchFight(nb.id)"></span>
	        	<span class="glyphicon glyphicon-plus" v-on:click="addFriends(nb.id)"></span>
	        </div>
	  	</div>
		<button class="back btn btn-default col-xs-12" style="position:fixed;left:0;bottom:0;" v-on:click="changeShow()">返回</button>
		</div>
		
		<div v-show="!nearby_show">
		<div class="col-xs-12" style="padding:0;margin-bottom:34px;">
	        <div class="col-xs-12 btn-lg ctrl-tab" v-for="firend in friends">
	        	<div class="col-xs-10">
	        	{{firend[1]}}<br/>
	        	</div>
	        	<span class="glyphicon glyphicon-scissors" v-on:click="searchFight(firend[0])"></span>
	        </div>
	  	</div>
	
		<button class="back btn btn-default col-xs-12" style="position:fixed;left:0;bottom:0;" v-on:click="friendsShow()">返回</button>
		</div>
	</div>
	
    <script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
	<script src="/dld/home/js/jquery.tap.js"></script>
	<script src="/dld/home/js/sweetalert.min.js"></script>
	<script src="http://cdn.bootcss.com/vue/1.0.24/vue.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=HXYw0NMPgfe5AGblvWr21nfwTSrhpszw"></script>
    <script>
    	var users_id = ${users.id};
    	
    	var vue = new Vue({
    		  el: '#app',
    		  data: {
    		    money: ${users.gameInfo.money},
    		    get_money: ${users.gameInfo.get_money},
    		    earn: 0,
    		    dug_location: '',
    		    
    		    ll: ${users.gameInfo.ll} <s:iterator value="users.goodsUse" status="st" var="list">+ ${users.goodsUse[st.index].ll}</s:iterator>,
    		    mj: ${users.gameInfo.mj} <s:iterator value="users.goodsUse" status="st" var="list">+ ${users.goodsUse[st.index].mj}</s:iterator>,
    		    zl: ${users.gameInfo.zl} <s:iterator value="users.goodsUse" status="st" var="list">+ ${users.goodsUse[st.index].zl}</s:iterator>,
    		    
    		    nearby: [],
    		    friends: [<s:iterator value="users.FItem" status="st" var="list">[
    		           '<s:property value="#list.getId()"/>',
    		           '<s:property value="#list.getName()"/>'
    		           ]</s:iterator>],
    		    
    		    main_ctrl: true,
    		    nearby_show: true,
    		    
    		    feedback:''
    		  },
    		  computed: {
    			  hp: function(){
    				  return ${users.gameInfo.hp} + 50 + this.ll * 5 <s:iterator value="users.goodsUse" status="st" var="list">+ ${users.goodsUse[st.index].hp}</s:iterator>;
    			  },
    			  ap: function(){
    				  return (this.zl <s:iterator value="users.goodsUse" status="st" var="list">+ ${users.goodsUse[st.index].ap}</s:iterator>).toFixed(2);
    			  },
    			  ad: function(){
    				  return (this.ll * 0.5 <s:iterator value="users.goodsUse" status="st" var="list">+ ${users.goodsUse[st.index].ad}</s:iterator>).toFixed(2);
    			  },
    			  hj: function(){
    				  return (this.mj * 0.2 <s:iterator value="users.goodsUse" status="st" var="list">+ ${users.goodsUse[st.index].hj}</s:iterator>).toFixed(2);
    			  },
    			  fib: function(){
    				  var a = this.get_money;
    			      var c=0,d,b,e;
    			      b=d=1;
    			      if(a==0)
    			            return 0;
    			      if(a==1 || a==2)
    			            return 1 * 100;
    			      else for (c=2; c<a; c++) {
    			            e=b;
    			            b=d+e;
    			            d=e;
    			      }
    			      return b * this.get_money;
    			  },
    		  },
    		  methods:{
    			  upProperty: function(propNum,prop){
    				  useMoney = propNum * 100;
    				  if(this.money < useMoney){
    					  swal("需要更多金币!");
    					  return ;
    				  }
    				  var that = this;
						$.ajax({
						    type: 'POST',
						    url: "UsersAddPropAction",
						   	data:{
						   		useMoney: useMoney,
						   		prop: prop,
						   	},
						    cache: false,
						    async: true,
						    success: function(data) {
						    	that.money = that.money - useMoney;
						    	if(prop == 'll') that.ll++;
						    	else if(prop == 'mj') that.mj++;
						    	else that.zl++;
						    },
						    error: function() {
						    	swal("网路出现错误!");
						    }
						});
    			  },
    			  upGetMoney: function(){
    				  if(this.money < this.fib){
    					  swal("需要更多金币!");
    					  return ;
    				  }
    				  var that = this;
						$.ajax({
						    type: 'POST',
						    url: "UsersAddGetMoneyAction",
						   	data:{
						   		fib: that.fib,
						   		get_money: that.get_money,
						   	},
						    cache: false,
						    async: true,
						    success: function(data) {
						    	that.money = that.money -that.fib;
						    	that.get_money++;
						    },
						    error: function() {
						    	swal("网路出现错误!");
						    }
						});
    			  },
    			  search: function(){
    				  if(this.money < 2000){
    					  swal("需要更多金币!");
    					  return ;
    				  }else if(start.lng == undefined){
    					  swal("请先定位!");
    					  return ;
    				  }
    				  var that = this;
						$.ajax({
						    type: 'POST',
						    url: "UsersCutMoneyAction",
						    cache: false,
						    async: true,
						    success: function(data) {
						    	that.money = that.money - 2000;
						    	
					    		var a = Math.floor(Math.random()*1000000+1) / 400000000;
					    		var b = Math.floor(Math.random()*1000000+1) / 400000000;
					    		console.log(a + ' ' + b);
					    		end.lng = (start.lng + a).toFixed(8);
					    		end.lat = (start.lat + b).toFixed(8);
					    		that.dug_location = '(' + end.lng + '),(' + end.lat + ')';
					    		console.log(end);
						    },
						    error: function() {
						    	swal("网路出现错误!");
						    }
						});
    			  },
    			  changeShow: function(){
    		        	if(start.lng == undefined){
    						  swal("请先定位!");
    						  return ;
    					}
    				  var that = this;
    				  this.main_ctrl = !this.main_ctrl;
    				  if(!this.main_ctrl){
  						$.ajax({
						    type: 'POST',
						    url: "UsersSeachAction",
						    cache: false,
						    async: true,
						    dataType: 'json',
						    success: function(data) {
						    	console.log(data.length);
								for(var o in data ){
									var users = [];
									users.id = data[o].id;
									users.name = data[o].name;
									users.sex = data[o].sex;
									users.location = data[o].location;
									var arr = data[o].location.split(",");
									var point = new Object();
									point.lng = arr[0];
									point.lat = arr[1];
									console.log(start);
									console.log(point);
									users.distance = (map.getDistance(new BMap.Point(start.lng, start.lat), new BMap.Point(point.lng, point.lat))).toFixed(2)+'米。';
									that.nearby.push(users);
								}
						    },
						    error: function() {
						    }
						});
    				  }else{
    					  that.nearby = [];
    				  }
    			  },
    			  friendsShow: function(){
    				  this.main_ctrl = !this.main_ctrl;
    				  this.nearby_show = !this.nearby_show;
    			  },
    			  searchFight: function(id){
    				  if(id == null){
	    				  window.location.href="UsersFindDfAction";
    				  }else{
    					  window.location.href="UsersFindDfAction?id=" + id;
    				  }
    			  },
    			  addFriends: function(id){
						$.ajax({
						    type: 'POST',
						    url: "UsersAddFriends",
						   	data:{
						   		id: id,
						   	},
						    cache: false,
						    async: true,
						    success: function(data) {
						    	window.location.reload();
						    },
						    error: function() {
						    	swal("网路出现错误!");
						    }
						});
    			  },
    			  submitFB: function(){
    				  console.log(this.feedback);
						$.ajax({
						    type: 'POST',
						    url: "logAddFbAction",
						   	data:{
						   		feedback: this.feedback,
						   	},
						    cache: false,
						    async: true,
						    success: function(data) {
						    	this.feedback = "";
						    	swal("反馈已提交，多谢您的意见!");
						    },
						    error: function() {
						    	swal("网路出现错误!");
						    }
						});
    			  }
    		  },
    		});
    	
    	var geolocation = new BMap.Geolocation();
    	var map = new BMap.Map("l-map");
    	var end = new Object();
    	var start = new Object();
        $(document).ready(function(){
            $('.user-detail-right').width(document.body.offsetWidth-130);
            $('.tab-content').height(document.body.scrollHeight-190);
        })
        
        $('.btn-click.money').on('tap',function(){
        	vue.earn = vue.earn + vue.get_money;
        });
        
        $('.dug').on('tap',function(){
        	if(start.lng == undefined){
				  swal("请先定位!");
				  return ;
			}
        	console.log(start.lng + '  ' + end.lng);
        	console.log(start.lat + '  ' + end.lat);
        	
        	//$('#l-map').height(300);
        	map.centerAndZoom(new BMap.Point(start.lng, start.lat), 11);
        	map.disableDragging();
        	var walking = new BMap.WalkingRoute(map, {renderOptions: {map: map, panel: "r-result", autoViewport: true}});
        	walking.search(new BMap.Point(start.lng, start.lat), new BMap.Point(end.lng, end.lat));
        	walking.setSearchCompleteCallback(function(){
        		console.log(walking.getResults());
        		console.log(walking.getResults().tr[0].getDistance());
        		if(walking.getResults().tr[0].getDistance() == '0米'){
        			var num = Math.floor(Math.random()*100+1);
        			if(num <=5){
        	            $.ajax({
        	                type: 'POST',
        	                url: "UsersGetSomeAction",
        	                data:{
        	                	get_type: "Goods"
        	                },
        	                cache: false,
        	                async: true,
        	                secureuri:false,
        	                success: function(data) {
        	                	swal("获得随机物品!" + data.result);
        	                	setTimeout(function(){
       		    			 		location.reload();
                             	}, 2000);
        	                },
        	                error: function() {
        	                	swal("网路出现错误!");
        	                }
        	            });
        			}else if(num <= 10){
        	            $.ajax({
        	                type: 'POST',
        	                url: "UsersGetSomeAction",
        	                data:{
        	                	get_type: "Skill"
        	                },
        	                cache: false,
        	                async: true,
        	                secureuri:false,
        	                success: function(data) {
        	                	swal("获得技能随机!" + data.result);
        	                	setTimeout(function(){
       		    			 		location.reload();
                             	}, 2000);
        	                },
        	                error: function() {
        	                	swal("网路出现错误!");
        	                }
        	            });
        			}else if(num <= 15){
       		        	var get_money = Math.floor(Math.random()*19999+1);
       		            $.ajax({
       		                type: 'GET',
       		                url: "UsersAddMoneyAction?earn=" + get_money,
       		                cache: false,
       		                async: true,
       		                success: function(data) {
       		                	swal("数额随机1-19999!");
       		                	vue.money = vue.money + get_money;
       		                },
       		                error: function() {
       		                	swal("网路出现错误!");
       		                }
       		            });
        			}else if(num <= 20){
        	            $.ajax({
        	                type: 'POST',
        	                url: "UsersGetSomeAction",
        	                data:{
        	                	get_type: "prop"
        	                },
        	                cache: false,
        	                async: true,
        	                secureuri:false,
        	                success: function(data) {
        	                	swal("属性随机!" + data.result);
       		    			 	setTimeout(function(){
       		    			 		location.reload();
                             	}, 2000);
        	                },
        	                error: function() {
        	                	swal("网路出现错误!");
        	                }
        	            });
        			}else if(num <= 25){
        				swal("遇到敌人,2s后开打!");
		    			 setTimeout(function(){
		    				 window.location.href="UsersFindDfAction";
                         }, 2000);
        			}
        		}
        	})
        });
        
        $('.money-update').on('tap',function(){
        	if(vue.earn == 0){
        		return;
        	}
            $.ajax({
                type: 'GET',
                url: "UsersAddMoneyAction?earn=" + vue.earn,
                cache: false,
                async: true,
                success: function(data) {
                	vue.money = vue.money + vue.earn;
                	vue.earn = 0;
                },
                error: function() {
                	swal("网路出现错误!");
                }
            });
        });
    	// 百度地图API功能
    	function getLocation(){
	    	geolocation.getCurrentPosition(function(r){
	    		if(this.getStatus() == BMAP_STATUS_SUCCESS){
	    			$('.gps').html('(' + r.point.lng+'),('+r.point.lat + ')');
	    			start.lng = r.point.lng;
	    			start.lat = r.point.lat;
	                $.ajax({
	                    type: 'GET',
	                    url: "UsersSetLocationAction?location=" + r.point.lng+','+r.point.lat,
	                    cache: false,
	                    async: true,
	                    success: function(data) {
	                    },
	                    error: function() {
	                    	swal("网路出现错误!");
	                    }
	                });
	    		}
	    		else {
	    			console.log('failed'+this.getStatus());
	    		}
	    	},{enableHighAccuracy: true})
    	}
    </script>
</body>

</html>
